package com.mcgrady.collection;

import org.junit.Test;

import java.util.*;
import java.util.zip.DeflaterOutputStream;

/**
 * @author McGrady
 */
public class IteratorTest {
    @Test
    public void iterList() {
        List<Integer> num = List.of(1, 3, 5, 7, 9, 2, 4, 6, 8, 0);
        Iterator<Integer> it = num.iterator();
        while (it.hasNext()) {
            System.out.println(it.next());
        }
    }

    @Test
    public void iterSet() {
        Set<Integer> set = new HashSet<>();
        set.add(1);
        set.add(3);
        set.add(5);
        set.add(7);
        set.add(9);
        Iterator<Integer> it = set.iterator();
        while (it.hasNext()) {
            System.out.println(it.next());
        }
    }

    @Test
    public void iterMap() {
        Map<String, Object> map = new HashMap<>(10);
        map.put("篮网", "总冠军");
        map.put("哈登", "MVP");
        map.put("杜兰特", "死神");
        map.put("欧文", "进攻万花筒");
        map.put("巨头数", 15);
        Iterator<Map.Entry<String, Object>> it = map.entrySet().iterator();
        while (it.hasNext()) {
            System.out.println(it.next());
        }
    }
}
